--预定义路径
supportDir="ZUI/support/"
freetypeDir="TTF/external/freetype/"
sdl2SrcDir="SDL2/src/"

if not isAndoid then
	isWin32=os.is("windows")
	isMac=os.is("macosx")
	isUnix=os.is("linux")
end

workspace "ZuiLib"
	configurations { "Debug", "Release" }
	
if not isAndoid then	
	platforms { "x32", "x64" }
end

    -- Get arguments passed to the command line
    for i=1, #_ARGS do
        if _ARGS[i] == "cygwin" then
			cygwin = true
			print("*****  Build using cygwin  *****") 
		elseif _ARGS[i] == "minGW" then
			minGW = true 
			print("*****  Build using minGW  *****")
		end
    end	
	
	if isAndoid then
	    location "android_proj/jni"
		ndkabi "all"
		ndkplatform "android-12"
		ndkstl "libstdc++"
	else
		location "build"
	end
	
	
    if isWin32 then
        defines { "_WIN32", "WIN32" }
        if minGW then defines { "__MINGW32__" } end
        if cygwin then defines { "__CYGWIN__" } end
    elseif isMac then 
		defines { "__APPLE__", "MACOSX","POSIX" }
    elseif isUnix then
		defines { "LINUX", "linux" ,"POSIX"}
    end	
	
	
	filter "configurations:Debug"
		defines { "DEBUG" }
		flags { "Symbols" }
		optimize "Debug"
		
	filter "configurations:Release"
		defines { "NDEBUG" }
		optimize "On"
		flags { "OptimizeSpeed", "EnableSSE2" }
	
	
--	configuration "windows"
--		prebuildcommands { "copy default.config bin\\project.config" }
	
project "base"
	kind "StaticLib"
	language "C++"
	files { "base/*.h", "base/*.cc","base/*.cpp","base/malloc/*.h", "base/malloc/*.c" }

project "tinyxml2"
	kind "StaticLib"
	language "C++"	
	files {"tinyxml2/tinyxml2.h","tinyxml2/tinyxml2.cpp"}
	
project "TTF"
	kind "StaticLib"
	language "C"	
	includedirs { freetypeDir.."include",freetypeDir.."include/freetype","SDL2/include"}
	files{"TTF/SDL_ttf.h","TTF/SDL_ttf.c"}
	
project "ZuiLib"

if isAndoid then
	kind "SharedLib"
else
	kind "WindowedApp"
end
	language "C++"
	
	includedirs{"SDL2/include","./"}
	
	files { 
		"ZUI/*.h", "ZUI/*.cpp",
		"ZUI/sdl_gfx/*.h", "ZUI/sdl_gfx/*.c",
		
		supportDir.."*.h",supportDir.."*.c",supportDir.."*.cpp",
		supportDir.."gif_lib/*.h",supportDir.."gif_lib/*.c",
	}

	if isWin32 then
		files{sdl2SrcDir.."main/windows/*.c",}
	elseif isAndoid then
		files {
            sdl2SrcDir.."/main/android/SDL_android_main.c",
        }
	else
		files{sdl2SrcDir.."main/dummy/*.c",}
	end	
	
if isWin32 then
	libdirs {"prebuild/win32"}
	links{"base","tinyxml2","libfreetype-6","SDL2","TTF"}
elseif isMac then
	libdirs {"prebuild/mac"}
	
	--file not found with <angled> include, use "quotes"  As a workaround, you can set the Xcode build setting "Always Search User Paths" to YES.
elseif isAndoid then
	links {
		"GLESv1_CM",
		"GLESv2",
		"log",
	}
	
	amk_includes {
		"SDL2/Android.mk",
	}

	amk_sharedlinks {
		"SDL2",
	}	

else
	--linux
	libdirs {"usr/local/lib"}
	links{"base","tinyxml2","freetype","SDL2","TTF","pthread"}
	linkoptions { "-Wl,-rpath=.","-fshort-wchar"}
end
	
	
	
